#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
	int i = 0;
	int j = 0;
	int a = 0;
	int b = 0;
	while (scanf("%d %d", &a, &b) != EOF)
	{
		int arr1[20][20];
		int arr2[20][20];
		for (i = 0; i < a;i++)
		{
			for (j = 0; j < b; j++)
			{
				scanf("%d", &arr1[i][j]);
				arr2[j][i] = arr1[i][j];
			}
		}
		for (i = 0; i < b; i++)
		{
			for (j = 0; j < a; j++)
			{
				printf("%d ", arr2[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}